<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">
  <xi:include href="layout.html" />
  <xi:include href="macros.html" />
  <head>
    <title>Project Dashboard</title>

  </head>

  <body>
	<div id="ctxtnav" class="nav"></div>

    <div id="content" class="pdashboard">
      <h1>Project: <em>${project.name}</em></h1>
	    <p>${project.description}</p>

	  <div class="info">
        <h2>Project Tickets Statistics</h2> 
          <br/><b>Tickets by Status</b>
            <py:if test="proj_progress_stat.stats.count">${progress_bar(proj_progress_stat.stats, proj_progress_stat.interval_hrefs, stats_href=proj_progress_stat.stats_href)}</py:if>
		  
          <br/><b>Tickets by Resolution</b>  
            <py:if test="proj_progress_stat.stats.count">${progress_bar(proj_closed_stat.stats, proj_closed_stat.interval_hrefs, stats_href=proj_closed_stat.stats_href)}</py:if>
      
      </div>
      
      <div>
      
      	<h2>Project Backlog Metrics</h2>
      	
      	<h3> Daily Backlog Statistics </h3>
      		<img src="${href.pdashboard('dailybacklog.png')}" alt="Backlog Graph"/>
      		      	
      	<h3> Monthly Backlog Metrics </h3>
  		  <table style="width: 800px" class="listing project stats">
	        <thead>
		      <tr>
			    <th style="width: 90px">Month</th>
			    <th style="width: 200px">Ticket Created</th>
			    <th style="width: 200px">Ticket Opened</th>
			    <th style="width: 200px">Ticket Closed</th>
			    <th style="width: 90px">Backlog Management Index (Closed/Opened)</th>
			  </tr>
		    </thead>
		    <tbody>
  			  <tr py:for="bmi in project_bmi_stats" >
			    <td style="width: 90px">${bmi[0]}</td>
			    <td style="width: 200px">${len(bmi[1])} ${wiki_to_html(context(), ', '.join(['#%s' % i for i in bmi[1]]))}</td>
			    <td style="width: 200px">${len(bmi[2])} ${wiki_to_html(context(), ', '.join(['#%s' % i for i in bmi[2]]))}</td>
			    <td style="width: 200px">${len(bmi[3])} ${wiki_to_html(context(), ', '.join(['#%s' % i for i in bmi[3]]))}</td>
			    <td style="width: 90px">${"%.2f %%" % (float(len(bmi[3])) * 100 / float(len(bmi[2])),)}</td>
			  </tr>
		    </tbody>		  
		  </table>
      </div>
      <br/>
      <div class="info">
      	<h2>Tickets Statistics:</h2>
		<table style="width: 800px" class="listing milestone">
	      <thead>
		    <tr>
			  <th style="width: 357px" class="style1">Metrics</th>
			  <th style="width: 219px">Mean</th>
			  <th style="width: 219px">Median</th>
			  <th style="width: 91px">Max</th>
			  <th style="width: 90px">Min</th>
			  <th style="width: 90px">Std. Dev.</th>
			</tr>
		  </thead>
		  <tbody>
  			<tr py:for="key in ticket_duration_stats" class="statistics">
			  <th style="width: 357px" class="style1">${key}</th>
			  <th style="width: 100px">${pretty_timedelta(0, ticket_duration_stats[key].avg())}</th>
			  <th style="width: 100px">${pretty_timedelta(0, ticket_duration_stats[key].median())}</th>
			  <th style="width: 91px">${pretty_timedelta(0, ticket_duration_stats[key].max())}</th>
			  <th style="width: 90px">${pretty_timedelta(0, ticket_duration_stats[key].min())}</th>
			  <th style="width: 90px">${pretty_timedelta(0, ticket_duration_stats[key].stdev())}</th>
			</tr>
  			<tr py:for="key in ticket_frequency_stats" class="statistics">
			  <th style="width: 357px" class="style1">${key}</th>
			  <th style="width: 100px">${"%.4f" % ticket_frequency_stats[key].avg()}</th>
			  <th style="width: 100px">${"%.4f" % ticket_frequency_stats[key].median()}</th>
			  <th style="width: 91px">${"%.4f" % ticket_frequency_stats[key].max()}</th>
			  <th style="width: 90px">${"%.4f" % ticket_frequency_stats[key].min()}</th>
			  <th style="width: 90px">${"%.4f" % ticket_frequency_stats[key].stdev()}</th>
			</tr>
		  </tbody>		  
		</table>
	  </div>
	  <br/>
	  <div class="info">
	
		<h2>Milestone Summary:</h2>
          <form method="get" action="">
      	    <div>
              <input type="checkbox" id="showall" name="show" value="all"
                     checked="${showall or None}" />
              <label for="showall">Show already completed milestones</label>
              <input type="submit" value="Update" />
            </div>
          </form>	
    		
		<table style="width: 800px" class="listing milestone">
	      <thead>
				<tr>
					<th style="width: 357px" class="style1">Milestone</th>
					<th style="width: 219px">Status</th>
					<th style="width: 91px">New</th>
					<th style="width: 90px">In-progress</th>
					<th style="width: 90px">Completed</th>
					<th style="width: 89px">Total</th>
					<th style="width: 100px">Complete</th>
				</tr>
			</thead>
			<tbody>
					<tr py:for="idx, milestone in enumerate(milestones)" class="milestone"
					    py:with="mstats = milestone_stats[idx]">
						<td style="width: 357px"><a href="${href.mdashboard(milestone.name)}">${milestone.name}</a></td>
						<td style="width: 219px">
							<py:choose>
								<p py:when="milestone.completed" class="date">
			                Completed ${dateinfo(milestone.completed)} ago
			                (${format_date(milestone.completed)})
			              	</p>
			              	<p py:when="milestone.is_late" class="date">
				             <strong>${dateinfo(milestone.due)} late</strong>
				                (${format_date(milestone.due)})
				             </p>
				             <p py:when="milestone.due" class="date">
				                Due in ${dateinfo(milestone.due)}
				                (${format_date(milestone.due)})
				             </p>
				             <p py:otherwise="" class="date">
				                No date set
				             </p>
			            </py:choose>
						</td>
						<td style="width: 91px"><a href="${mstats.interval_hrefs[2]}">${mstats.stats.intervals[2].count}</a></td>
						<td style="width: 90px"><a href="${mstats.interval_hrefs[1]}">${mstats.stats.intervals[1].count}</a></td>
						<td style="width: 90px"><a href="${mstats.interval_hrefs[0]}">${mstats.stats.intervals[0].count}</a></td>
						<td style="width: 89px"><a href="${mstats.stats_href}">${sum([x.count for x in mstats.stats.intervals], 0)}</a></td>
						<td style="width: 100px">${'%d%%' % mstats.stats.done_percent}</td>
					</tr>
			</tbody>			
		</table>
      </div>
    </div>

	<div>
	  <h2> Repository Statistics </h2>
	    <img src="${href.pdashboard('commitsbydate.png')}" alt="Commits by Date"/>
	</div>

    <div id="help"><strong>Note:</strong> See
      <a href="${href.wiki('TracRoadmap')}">TracRoadmap</a> for help on using
      the roadmap.
    </div>

  </body>
</html>
